<%@ page import="assignmentonepenguins.Listing" %>
<!doctype html>
<html>
<head>
    <meta name="layout" content="main">
    <g:set var="entityName" value="${message(code: 'listing.label', default: 'Listing')}"/>
    <g:set var="custEntityName" value="${message(code: 'customer.label', default: 'Customer')}"/>
    <title><g:message code="default.list.label" args="[entityName]"/></title>
</head>

<body>
<a href="#list-listing" class="skip" tabindex="-1"><g:message code="default.link.skip.label"
                                                              default="Skip to content&hellip;"/></a>

<div class="nav" role="navigation">
    <ul>
        <li><g:link class="list" action="list" controller="listing"><g:message code="Home"
                                                                               args="[entityName]"/></g:link></li>
        <li><g:link class="create" action="create"><g:message code="default.new.label"
                                                              args="[entityName]"/></g:link></li>
        <li><g:link class="list" action="list" controller="customer"><g:message code="default.list.label"
                                                                                args="[custEntityName]"/></g:link></li>
        <li><g:link class="list" action="list" controller="listing"><g:message code="My Listings"
                                                                               args="[entityName]"/></g:link></li>
    </ul>
</div>

<div id="list-listing" class="content scaffold-list" role="main">
    <h1><g:message code="default.list.label" args="[entityName]"/></h1>
    <g:if test="${flash.message}">
        <div class="message" role="status">${flash.message}</div>
    </g:if>
    <table>
        <thead>
        <tr>

            <th><g:message code="listing.biddings.name" default="Name"/>

            <th><g:message code="listing.biddings.label" default="# of Bids"/>

            <g:sortableColumn property="startBid"
                              title="${message(code: 'listing.startBid.label', default: 'Start Bid')}"/>

            <g:sortableColumn property="endDate"
                              title="${message(code: 'listing.endDate.label', default: 'End Date')}"/>

        </tr>
        </thead>
        <tbody>
        <g:each in="${listingInstanceList}" status="i" var="listingInstance">
            <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">

                <td><g:link action="show"
                            id="${listingInstance.id}">${fieldValue(bean: listingInstance, field: "name")}</g:link></td>

                <td><g:formatNumber number="${listingInstance.biddings.size()}"/></td>

                <td>$${fieldValue(bean: listingInstance, field: "startBid")}</td>

                <td><g:formatDate format="hh:mmaa MMM-dd-yyyy" date="${listingInstance.endDate}"/></td>

            </tr>
        </g:each>
        </tbody>
    </table>

    <div class="pagination">
        <g:paginate total="${listingInstanceTotal}"/>
    </div>
</div>
</body>
</html>
